<template>
  <div class="px-[15px]">
    <div class="border-b border-[#ECECEC] py-[15px] flex items-center w-full">
      <div class="text-[14px] min-w-[100px]">保单号</div>
      <div class="ml-[10px] flex justify-between items-center w-full">
        <div class="text-[14px]">
          {{ bdInfo?.bd_no }}
        </div>
      </div>
    </div>
    <div class="border-b border-[#ECECEC] py-[15px] flex items-center w-full">
      <div class="text-[14px] min-w-[100px]">电子保单</div>
      <div class="ml-[10px] flex justify-between items-center w-full">
        <div class="text-[14px]" v-if="bdInfo?.bd_url">
          <van-button type="primary" @click="download" size="small"
            >下载电子保单</van-button
          >
        </div>
        <div class="text-[14px]" v-else>
          <van-button type="primary" size="small" @click="load"
            >获取电子保单</van-button
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, defineEmits } from "vue";
import { getBd } from "@/utils/api";
const props = defineProps({
  bdInfo: { type: Object },
});
const emit = defineEmits(["getInfo"]);
//下载
const download = () => {
  window.open(props.bdInfo?.bd_url);
};
//获取
const load = async () => {
  const res = await getBd({ id: props.bdInfo?.id });
  if (res.code == 1) {
    emit("getInfo");
  }
};
</script>
<style scoped lang="scss"></style>
